#include "model/Attribute.h"
#include <iostream>
#include <string>
#include <sstream>
#include "model/Diagram.h"
#include "gui/Dibujar/Defines.h"

Attribute::Attribute(const std::string & name, int orientation)
: Component(name, orientation){
	initializeConnectors();
}


Attribute::Attribute(const Attribute & otro) : Component(otro){
	if(otro.m_name.find(TARGET_ATTRIBUTE) == 0)
		m_name = TARGET_ATTRIBUTE;
	initializeConnectors();
}


Attribute& Attribute::operator=(const Attribute& otro) {
	if(otro.m_name.find(TARGET_ATTRIBUTE) == 0)
		m_name = TARGET_ATTRIBUTE;
	Component::operator=(otro);
	initializeConnectors();
	return *this;
}


void Attribute::initializeConnectors() {

	addConnector( ATTRIBUTE_ONLY_CONECTOR, false);
}


void Attribute::serialize(XmlWriter & writer_rep, XmlWriter & writer_comp)
{
	writer_rep.addRootChild(TARGET_ATTRIBUTE, "");
	XmlWriter xml_dummy("dummy");
	Component::serialize(writer_rep, xml_dummy);
}

void Attribute::addToDiagram(Diagram &diagram){
	diagram.addAttribute(this);
}


void Attribute::removeFromDiagram(Diagram &diagram){
	diagram.removeAttribute(this);
}
